﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_Admin : System.Web.UI.MasterPage
{
   
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["QuanTri"] != null)
        {
            quantri = bool.Parse(Session["QuanTri"].ToString());
        }
        else
        {
            Response.Redirect("Login.aspx");
        }
    }
    public bool quantri;
    public bool nhiemvuQT;
    public bool nhiemvuNV;
    public bool QuanTri()
    {
        return this.quantri;
    }

    public bool NhiemVuQT(int i)
    {

        string sfile = Server.MapPath("~/dataQTV.txt");
        using (System.IO.StreamReader reader = new System.IO.StreamReader(sfile))
        {
            string snoidung = reader.ReadToEnd();

            string[] tem = snoidung.Split(new Char[] { '\r', '\n' });
            return this.nhiemvuQT = bool.Parse(tem[i]);

        }
    }
    public bool NhiemVuNV(int i)
    {

        string sfile = Server.MapPath("~/dataNV.txt");
        using (System.IO.StreamReader reader = new System.IO.StreamReader(sfile))
        {
            string snoidung = reader.ReadToEnd();

            string[] tem = snoidung.Split(new Char[] { '\r', '\n' });
            return this.nhiemvuNV = bool.Parse(tem[i].ToString());

        }
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        int vtLoai = DropDownList1.SelectedIndex;
        if (vtLoai > 0 && txtTimKiem.Value != "Tìm kiếm")
        {
            string tenSP = txtTimKiem.Value;
            string loaiSP = DropDownList1.SelectedValue;
            switch (int.Parse(loaiSP))
            {
                case 1:
                    Response.Redirect("SearchResult.aspx?LoaiTK=" + loaiSP + "&ChuoiTimKiem=" + tenSP);
                    break;
                case 2:
                    Response.Redirect("SearchResult.aspx?LoaiTK=" + loaiSP + "&ChuoiTimKiem=" + tenSP);
                    break;
                case 3:
                    Response.Redirect("SearchResult.aspx?LoaiTK=" + loaiSP + "&ChuoiTimKiem=" + tenSP);
                    break;
                case 4:
                    Response.Redirect("SearchResult.aspx?LoaiTK=" + loaiSP + "&ChuoiTimKiem=" + tenSP);
                    break;
            }

        }
        if (vtLoai > 0 && txtTimKiem.Value == "Tìm kiếm")
        {
            // string tenSP = txtTimKiem.Value;
            string loaiSP = DropDownList1.SelectedValue;
            switch (int.Parse(loaiSP))
            {
                case 1:
                    Response.Redirect("SearchResult.aspx?LoaiTK=" + loaiSP + "&ChuoiTimKiem=");
                    break;
                case 2:
                    Response.Redirect("SearchResult.aspx?LoaiTK=" + loaiSP + "&ChuoiTimKiem=");
                    break;
                case 3:
                    Response.Redirect("SearchResult.aspx?LoaiTK=" + loaiSP + "&ChuoiTimKiem=");
                    break;
                case 4:
                    Response.Redirect("SearchResult.aspx?LoaiTK=" + loaiSP + "&ChuoiTimKiem=");
                    break;
            }

        }

        Response.Redirect("SearchResult.aspx?LoaiTK=&ChuoiTimKiem=");
    }
    protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {
        Session["UserType"] = null;
        Session["UserID"] = null;
        Response.Redirect("Login.aspx");
    }
}
